package com.project.atomikosspringboot.configuration;

import javax.sql.DataSource;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jta.atomikos.AtomikosDataSourceBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

@Configuration
public class DataSourceConfiguration {

	@Primary
	@Bean(name = "primaryDataSource")
	@ConfigurationProperties("spring.jta.atomikos.datasource.primary")
	public DataSource primaryDataSource() {
		return new AtomikosDataSourceBean();
	}
	
	@Bean(name = "secondaryDataSource")
	@ConfigurationProperties("spring.jta.atomikos.datasource.secondary")
	public DataSource secondaryDataSource() {
		return new AtomikosDataSourceBean();
	}
}
